Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate JAXB v4. #73

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Integrate JAXB v4. #73

wants to merge 4 commits into from

Conversation

dmak
Copy link
Owner

@dmak dmak commented Jan 22, 2023

  • Integrate JAXB v4.
  • Drop Java 8 support.

Depends on: issue #1678.

@dmak dmak force-pushed the master branch 3 times, most recently from 1d2dcc1 to 78ffb1a Compare January 23, 2023 13:57
@plebcity
Copy link

When is this going to be merged?

@dmak
Copy link
Owner Author

dmak commented Oct 10, 2023

No particular deadlines at the moment. There have been a few unit tests failing, which I decoded to revisit later, but that didn't happen yet. Good there is an interest, that motivates to finalize the changes.

@plebcity
Copy link

No particular deadlines at the moment. There have been a few unit tests failing, which I decoded to revisit later, but that didn't happen yet. Good there is an interest, that motivates to finalize the changes.

The EU DSS library devs were waiting for the org.jvnet.jaxb:jax-maven-plugin v4 to be released. This version was released last week with JAXB 4 support. But they still use your plugin aswell but it doesn't support JAXB 4 yet. This blocks their Javax -> Jakarta update and therefor blocks our Spring Boot 2 -> 3 update of which version 2 is end of life next month.

So there seems to be a lot connected to this particular plugin, it would be a great joy if you could find some time to fix the failing tests and merge this MR sooner rather than later.

@dmak
Copy link
Owner Author

dmak commented Oct 12, 2023

Give me a few weeks, I'll make my best to merge & release a new version. End of Q3 a bit crazy...

@martinIrzyk
Copy link

It seems that only XmlElementWrapperPluginTest is failing. I was trying to figure out why and it seems there is some problem with loading proper JAXBContextFactory from jaxb.properties for inner_element_value_objects package. I was able to fix it by adding conditional creation of JAXBContext via custom jaxbContextFactory from jaxb.properties in compileAndLoad method:

URLClassLoader newClassLoader = new URLClassLoader(
		            new URL[] { new File(GENERATED_SOURCES_PREFIX).toURI().toURL() }, currentClassLoader);
//start custom jaxbContextFactory
		try {
			Properties jaxbProperties = new Properties();
			InputStream inputStream = newClassLoader.getResourceAsStream(packageName + "/jaxb.properties");
			if(inputStream != null) {
				jaxbProperties.load(inputStream);
				if(jaxbProperties.containsKey(JAXBContext.JAXB_CONTEXT_FACTORY)){
					Class<?> jaxbContextFactory = newClassLoader.loadClass(jaxbProperties.getProperty(JAXBContext.JAXB_CONTEXT_FACTORY));
					Method m = jaxbContextFactory.getMethod("createContext", String.class, ClassLoader.class, Map.class);
					Object context = m.invoke(jaxbContextFactory, packageName, newClassLoader, Collections.<String,Object>emptyMap());
					if (!(context instanceof JAXBContext)) {
						throw new RuntimeException("JaxbContextFactory should create proper JAXBContext");
					}
					return (JAXBContext) context;
				}
			}
		} catch (IOException | NoSuchMethodException | ClassNotFoundException | InvocationTargetException |
                 IllegalAccessException e) {
			throw new RuntimeException(e);
		}
//end
        return JAXBContext.newInstance(packageName, newClassLoader);

It looks ugly, but worked. Also I bumped jaxb-api.version to 4.0.1, removed dependency to io.earcam.wrapped:jdk.compile and add exclusions for org.xmlunit:xmlunit-jakarta-jaxb-impl (for jakarta.xml.bind-api and jaxb-runtime)

hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants